/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.isn.historiaclinica.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlTransient;

import com.isn.atencionemergencia.entity.AnimalMordedor;

/**
 *
 * @author pool
 */
@Entity
@Table(name = "distrito")
public class Distrito implements Serializable {
    private static final long serialVersionUID = 1L;
   
    @EmbeddedId
    protected DistritoPK distritoPK;
    
    
    @Column(name = "Desc_Distri")
    private String descDistri;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codDistri")
    private Collection<AnimalMordedor> animalMordedorCollection;
    @JoinColumns({
        @JoinColumn(name = "Cod_Prov", referencedColumnName = "Cod_Prov", insertable = false, updatable = false),
        @JoinColumn(name = "Cod_Depa", referencedColumnName = "Cod_Depa", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Provincia provincia;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codDistri")
    private Collection<HistoriaClinica> historiaClinicaCollection;

    public Distrito() {
    }

    
    public Distrito(DistritoPK distritoPK) {
        this.distritoPK = distritoPK;
    }

    public Distrito(String codDistri, String codProv, String codDepa) {
        this.distritoPK = new DistritoPK(codDistri, codProv, codDepa);
    }
    
    public DistritoPK getDistritoPK() {
        return distritoPK;
    }

    public void setDistritoPK(DistritoPK distritoPK) {
        this.distritoPK = distritoPK;
    }

	public String getDescDistri() {
        return descDistri;
    }

    public void setDescDistri(String descDistri) {
        this.descDistri = descDistri;
    }

    @XmlTransient
    public Collection<AnimalMordedor> getAnimalMordedorCollection() {
        return animalMordedorCollection;
    }

    public void setAnimalMordedorCollection(Collection<AnimalMordedor> animalMordedorCollection) {
        this.animalMordedorCollection = animalMordedorCollection;
    }

    public Provincia getProvincia() {
        return provincia;
    }

    public void setProvincia(Provincia provincia) {
        this.provincia = provincia;
    }

    @XmlTransient
    public Collection<HistoriaClinica> getHistoriaClinicaCollection() {
        return historiaClinicaCollection;
    }

    public void setHistoriaClinicaCollection(Collection<HistoriaClinica> historiaClinicaCollection) {
        this.historiaClinicaCollection = historiaClinicaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (distritoPK != null ? distritoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Distrito)) {
            return false;
        }
        Distrito other = (Distrito) object;
        if ((this.distritoPK == null && other.distritoPK != null) || (this.distritoPK != null && !this.distritoPK.equals(other.distritoPK))) {
            return false;
        }
        return true;
    }
    	
}
